package com.its.common.net.core.codec;

import cn.hutool.core.util.ReflectUtil;
import io.netty.handler.codec.ByteToMessageDecoder;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @Author xiaxp
 * @Date 9/13/22 13:28
 * @Description
 */
@Data
public class DecoderBuildParams {
    private Class<? extends ByteToMessageDecoder> decoderClass;
    private Object[] constructorParams;

    public DecoderBuildParams(Class<? extends ByteToMessageDecoder> decoderClass){
        this.decoderClass = decoderClass;
    }

    public DecoderBuildParams(Class<? extends ByteToMessageDecoder> decoderClass, Object... constructorParams){
        this.decoderClass = decoderClass;
        this.constructorParams = constructorParams;
    }

    public ByteToMessageDecoder buildDecoderInstance(){
        return ReflectUtil.newInstance(decoderClass, constructorParams);
    }
}
